package com.ch08;

/**
 * @ClassName Student
 * @Description 单例模式(懒汉式写法) 有线程安全问题
 * @Author Kx
 * @Date 2025/4/17 14:55
 * @Version 1.0
 */
public class Student {
    private static Student student;

    // 私有化构造方法
    private Student(){

    }

    /***
     * @author: kx
     * @date: 2025/4/17 14:58
     * @return com.ch08.Student
     * @description: 提供一个方法获取实例
     */
    public static synchronized Student getInstance() {
        // 判断实例是否为空
        if (student == null) {
            student = new Student();
        }
        return student;
    }
}
